package com.vint.lintcode;

import com.vint.common.ListNode;


/**
 * 交换链表中两个节点，链表中值各不相同
 */
public class Lintcode511 {
	public ListNode swapNodes(ListNode head, int v1, int v2) {
		ListNode prev1 = fetchPre(head, v1);
		ListNode prev2 = fetchPre(head, v2);
		if (null != prev1 && null != prev2) {
			ListNode n1 = prev1.next;
			ListNode n2 = prev2.next;
			//prev1.next =
		}
		return head;
	}

	//找到pre节点，如果是root则null
	private ListNode fetchPre(ListNode head, int v){
		if(head.val == v) return null;
		ListNode pre = head;
		head = head.next;
		while (null!=head){
			head = head.next;
		}
		return pre;
	}
	public static void main(String[] args) {
		ListNode r1 = new ListNode(3);
		ListNode r2 = new ListNode(3);
		ListNode r3 = new ListNode(3);
		r1.next = r2;
		r2.next = r3;
		r3.next = r1;
		Lintcode511 lintcode466 = new Lintcode511();
		//System.out.println(lintcode466.countNodes(r1));

	}
}
